package com.yanqu.road.server.cmd.activity.shuihuyezicard;

import com.yanqu.road.pb.activity.ShuiHuYeZiCardProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.shuihuyezicard.ShuiHuYeZiCardMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/12/17 15:56
 */
@Cmd(code = GameProtocol.S_SHUIHUYEZICARD_PVP_SEND_MESSAGE, desc = "水浒叶子牌 pvp发送聊天")
public class ShuiHuYeZiCardPvpSendMessage extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ShuiHuYeZiCardProto.ShuiHuYeZiCardSendMessageReqMsg reqMsg = ShuiHuYeZiCardProto.ShuiHuYeZiCardSendMessageReqMsg.parseFrom(packet.getBytes());
        ret = ShuiHuYeZiCardMgr.canEntryActivity(player,reqMsg.getActivityId());
        if(ret != 0){
            return;
        }

        player.sendPacket(CrossProtocol.C_CROSS_SHUIHUYEZICARD_PVP_SEND_MESSAGE, reqMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            ShuiHuYeZiCardProto.ShuiHuYeZiCardSendMessageRespMsg.Builder resp = ShuiHuYeZiCardProto.ShuiHuYeZiCardSendMessageRespMsg.newBuilder();
            resp.setRet(ret);
            player.sendPacket(ClientProtocol.U_SHUIHUYEZICARD_PVP_SEND_MESSAGE,resp);
        }
    }
}
